<?php
namespace Attendance\Controller;
use Common\Controller\AdminbaseController;
// +----------------------------------------------------------------------
// | Date:2017年5月3日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 此文件作用于****
// +----------------------------------------------------------------------
class ClockController extends AdminbaseController{
    
    protected $model;
    public function _initialize(){
        $this->model=D('Attendance');
    }
    
    public function index(){
        $start_time = I('start_date');
        $end_time = I('end_date');
        $name = I('name');
        $where = json_decode(urldecode(I('map')),true);
        if ($start_time) $where['date'] = $start_time;
        if ($start_time && $end_time) $where['date'] = ['between',["$start_time 00:00:00","$end_time 23:59:59"]];
        if ($name) $where['name'] = ['like',"%{$name}%"];
        if (I('print')) {
            if (!$where) $this->error('请输入查询条件'); 
            $list = $this->model->where($where)->order('id desc')->select();
        }else{
            $list = $this->lists($this->model,$where,'id desc');
        }
        $this->assign('list',$list);
        $this->show_print(ACTION_NAME,'考勤打卡记录');
        if ($where) $this->assign('map',urlencode(json_encode($where)));
        $this->display();
    }
    
    
}